﻿<%@ Page Title="Attribute X Attribute families" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="AttributeXAttributefamilies.aspx.cs" Inherits="ColorApplication.color.AttributeXAttributefamilies" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="adminContent">
        <h2>Attributes X Attributes families
        </h2>
        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
            <ProgressTemplate>
                <div id="modalPage" runat="server" class="modalPage">
                    <div class="modalBackground">
                    </div>
                    <div class="modalContainer">
                        <div class="modal">
                            <table>
                                <tr>
                                    <td align="center">
                                        <div style="background-color: White; border-radius: 5px; color: black; height: 47px;
                                            padding-top: 5px;">
                                            Please Wait...
                                        <br />
                                            <img src="../Images/preloader.gif" />
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="ErrorLabel" runat="server" CssClass="failureNotification"></asp:Label>
                <asp:Label ID="SuccesLabel" runat="server" CssClass="successNotification"></asp:Label>
                <asp:DetailsView ID="AttributesXAttributesfamiliesDetailsView" runat="server" Height="50px"
                    Width="100%" AutoGenerateRows="False" DataKeyNames="Id" DataSourceID="AttributeXAttributeFamiliesDatailsSqlDataSource1"
                    DefaultMode="Insert" OnItemInserted="AttributesXAttributesfamiliesDetailsView_ItemInserted"
                    OnItemUpdated="AttributesXAttributesfamiliesDetailsView_ItemUpdated" OnItemInserting="AttributesXAttributesfamiliesDetailsView_ItemInserting"
                    OnItemUpdating="AttributesXAttributesfamiliesDetailsView_ItemUpdating">
                    <Fields>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:TemplateField HeaderText="Attribute" SortExpression="AttributeId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditAttributeDropDownList" runat="server" Text='<%# Bind("AttributeId") %>'
                                    DataSourceID="EditAttributeSqlDataSource" DataTextField="Description" DataValueField="Id">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="EditAttributeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    SelectCommand="GetAttributesSelect" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="EditAttributeRequiredFieldValidator1" runat="server"
                                    ControlToValidate="EditAttributeDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select an attribute."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertAttributeDropDownList" runat="server" Text='<%# Bind("AttributeId") %>'
                                    DataSourceID="InsertAttributeSqlDataSource" DataTextField="Description" DataValueField="Id"
                                    OnDataBound="InsertAttributeDropDownList_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertAttributeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    SelectCommand="GetAttributesSelect" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertAttributeRequiredFieldValidator1" runat="server"
                                    ControlToValidate="InsertAttributeDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select an attribute."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("AttributeId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Attributes Families" SortExpression="AttributesfamiliesId">
                            <EditItemTemplate>
                                <asp:DropDownList ID="EditAttributeFamiliesDropDownList" Text='<%# Bind("AttributesfamiliesId") %>'
                                    runat="server" DataSourceID="EditAttributeFamiliesSqlDataSource" DataTextField="Description"
                                    DataValueField="Id">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="EditAttributeFamiliesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    CancelSelectOnNullParameter="False" SelectCommand="GetAttributesfamiliesSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="EditAttributefamiliesRequiredFieldValidator" runat="server"
                                    ControlToValidate="EditAttributeFamiliesDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select Attribute families."></asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <InsertItemTemplate>
                                <asp:DropDownList ID="InsertAttributeFamiliesDropDownList" Text='<%# Bind("AttributesfamiliesId") %>'
                                    runat="server" DataSourceID="InsertAttributeFamiliesSqlDataSource" DataTextField="Description"
                                    DataValueField="Id" OnDataBound="InsertAttributeFamiliesDropDownList_DataBound">
                                </asp:DropDownList>
                                <asp:SqlDataSource ID="InsertAttributeFamiliesSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                                    CancelSelectOnNullParameter="False" SelectCommand="GetAttributesfamiliesSelect"
                                    SelectCommandType="StoredProcedure">
                                    <SelectParameters>
                                        <asp:Parameter Name="Id" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:RequiredFieldValidator ID="InsertAttributefamiliesRequiredFieldValidator" runat="server"
                                    ControlToValidate="InsertAttributeFamiliesDropDownList" CssClass="failureNotification"
                                    Display="Dynamic" ErrorMessage="Please select Attribute families."></asp:RequiredFieldValidator>
                            </InsertItemTemplate>
                            <ItemTemplate>
                                <asp:Label ID="Label2" runat="server" Text='<%# Bind("AttributesfamiliesId") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="AttributeXAttributeFamiliesDatailsSqlDataSource1" runat="server"
                    CancelSelectOnNullParameter="False" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    InsertCommand="InsertAttributesAttributesfamiliesInsert" InsertCommandType="StoredProcedure"
                    SelectCommand="GetAttributesAttributesfamiliesSelect" SelectCommandType="StoredProcedure"
                    UpdateCommand="UpdateAttributesAttributesfamiliesUpdate" UpdateCommandType="StoredProcedure">
                    <InsertParameters>
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                        <asp:Parameter Name="AttributesfamiliesId" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="AttributesXAttributesfamiliesGridView" Name="Id"
                            PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                        <asp:Parameter Name="AttributesfamiliesId" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <br />
                <br />
                <asp:GridView ID="AttributesXAttributesfamiliesGridView" runat="server" AutoGenerateColumns="False"
                    DataKeyNames="Id" DataSourceID="AttributesXAttributesfamiliesGridSqlDataSource"
                    Width="100%" OnRowDataBound="AttributesXAttributesfamiliesGridView_RowDataBound"
                    OnSelectedIndexChanged="AttributesXAttributesfamiliesGridView_SelectedIndexChanged"
                    AllowSorting="true">
                    <Columns>
                        <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                            SortExpression="Id" Visible="False" />
                        <asp:BoundField DataField="Attribute" HeaderText="Attribute" SortExpression="Attribute" />
                        <asp:BoundField DataField="AttributeFamilies" HeaderText="Attribute Families" SortExpression="AttributeFamilies" />
                        <asp:CommandField SelectText="Edit" ShowSelectButton="True" />
                        <asp:TemplateField ShowHeader="False">
                            <ItemTemplate>
                                <asp:LinkButton ID="DeleteLinkButton" runat="server" CausesValidation="False" CommandName="Delete"
                                    Text="Delete"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="AttributesXAttributesfamiliesGridSqlDataSource" runat="server"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" DeleteCommand="DeleteAttributesAttributesfamiliesDelete"
                    DeleteCommandType="StoredProcedure" SelectCommand="GetSeacrhAttributesAttributesfamiliesSelect"
                    SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="False">
                    <DeleteParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                    </DeleteParameters>
                    <SelectParameters>
                        <asp:Parameter Name="Id" Type="Int32" />
                        <asp:Parameter Name="AttributeFamiliesId" Type="Int32" />
                        <asp:Parameter Name="AttributeId" Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
